import React from 'react';
import { Input, Radio } from 'antd';
import { BaseComponent } from 'fe-lib';

/* eslint-disable */
class FlowApprove extends BaseComponent {
  constructor(props) {
    super(props);
    this.state = {};
    super.bind('handleAction', 'handleText');
  }

  handleAction(e) {
    this.setState({ actionId: e.target.value }, () => {
      this.props.onChange({ ...this.state, instanceId: this.props.instanceId });
    });
  }

  handleText(e) {
    this.setState({ message: e.target.value }, () => {
      if (this.state.actionId) {
        this.props.onChange({ ...this.state, instanceId: this.props.instanceId });
      }
    });
  }

  render() {
    const { actions } = this.props;
    const { message, actionId } = this.state;
    return (
      <div>
        <div>
          <Radio.Group value={actionId} onChange={this.handleAction}>
            {
              actions.map(item => <Radio key={item.id} value={item.id} >{item.name}</Radio>)
            }
          </Radio.Group>
        </div>
        <Input.TextArea onChange={this.handleText} value={message} placeholder="审核意见" />
      </div>
    )
  }


}

export default FlowApprove;
